import java.util.Arrays;
import java.util.List;

public class FullReductionPromotionCalculator implements PromotionCalculator{


    private static final SalesPromotion salesPromotion = new SalesPromotion("BUY_30_SAVE_6_YUAN",
            "Deduct 6 Yuan when the order reaches 30 Yuan", Arrays.asList());

    public PromotionResult calculate(List<OrderItem> orderItems) {
        Double totalAmount = orderItems.stream().map(OrderItem::getAmount).reduce(Double::sum).get();
        double saveAmount = totalAmount > 30 ? 6 : 0;
        return new PromotionResult(saveAmount, salesPromotion);
    }
}
